<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@page isELIgnored="false" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <base href="<%=basePath%>">
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>评价管理</title>
    <link rel="stylesheet" href="render/css/frontend/common/base.css" type="text/css"/>
    <link rel="stylesheet" href="render/css/frontend/common/shop_common.css" type="text/css"/>
    <link rel="stylesheet" href="render/css/frontend/shop_header.css" type="text/css"/>
    <link rel="stylesheet" href="render/css/frontend/shop_manager.css" type="text/css"/>
    <link rel="stylesheet" href="render/css/frontend/shop_list.css" type="text/css"/>

    <style type="text/css">
        .line-white{
            word-break: break-all;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            padding-left: 11px;
            padding-right: 11px;
        }
        .line-white:hover {
            text-decoration: none;
        }
        .time_right{
            float: right;
            color: red;
        }
        td.pingjia_title {
            padding: 8px;
        }
        #tuijian_content_1_empty {
            /* margin: 80px 0; */
            margin: 72px 0px 72px 0px !important;
            text-align: center;
            font-size: 33px;
            width: 100% !important;
            color: red;
        }
    </style>

    <script type="text/javascript" src="render/js/jquery.min.js"></script>
</head>
<body>
<!-- Header Start -->
<jsp:include page="common/head.jsp"></jsp:include>

<!-- TopHeader Center -->
<jsp:include page="common/topheader_center.jsp"></jsp:include>
<!-- TopHeader Center End -->

<!-- Header Menu -->
<jsp:include page="common/header_menu.jsp"></jsp:include>
<!-- Header Menu End -->

<div class="shop_hd_breadcrumb">
    <strong>当前位置：</strong>
    <span>
        <a href="/">首页</a>&nbsp;›&nbsp;
        <a href="/render/myhome">个人中心</a>&nbsp;›&nbsp;
        <a href="/render/comment">评价管理</a>
    </span>
</div>
<div class="clear"></div>
<!-- 面包屑 End -->
<!-- Header End -->

<!-- 我的个人中心 -->
<div class="shop_member_bd clearfix">
    <!-- 左边导航 -->
    <jsp:include page="common/myshop_left.jsp"></jsp:include>
    <!-- 左边导航 End -->

    <!-- 右边购物列表 -->
    <div class="shop_member_bd_right clearfix">
        <div class="shop_meber_bd_good_lists clearfix">
            <div class="title"><h3>订单列表</h3></div>
            <table>
                <thead class="tab_title">
                    <th style="width:80px;"><span>订单号</span></th>
                    <th style="width:320px;"><span>评价内容</span></th>
                    <th style="width:180px;"><span>被赞踩数</span></th>
                    <th style="width:100px;"><span>宝贝信息</span></th>
                    <th style="width:115px;"><span>操作</span></th>
                </thead>
                <tbody>
                    <tr>
                        <td colspan="5">
                            <table class="good" style="height:50px">
                                <tbody>
                                    <c:if test="${!empty pb.beanList}">
                                        <c:forEach items="${pb.beanList}" var="comment">
                                            <tr id="${comment.id}">
                                                <td class="pingjia_pic">
                                                    <span class="pingjia_type pingjia_type_1"></span>${comment.orderitem_id}
                                                </td>
                                                <td class="pingjia_title">
                                                    <span><a class="line-white" href="javascript:void(0);">${comment.content}</a></span>
                                                    <br/>
                                                    <span class="time_right">评论时间：<fmt:formatDate type="both" dateStyle="long" timeStyle="long" value="${comment.create_time}" /></span>
                                                </td>
                                                <td class="pingjia_danjia">
                                                    <span><strong>被点赞：${comment.support==null?0:comment.support}</strong></span>
                                                    <br>
                                                    <br>
                                                    <span><strong>被踩：${comment.oppose==null?0:comment.oppose}</strong></span>
                                                </td>
                                                <td class="pingjia_shuliang">
                                                    <span>
                                                        <a class="line-white" href="/render/product/product_detail?id=${comment.product_id}">${comment.orderItem.product_name}</a>
                                                        <p>${comment.orderItem.quantity}(元)</p>
                                                    </span>
                                                </td>
                                                <td class="pingjia_caozuo">
                                                    <span>
                                                        <a href="javascript:void(0);" onclick="deleteComment('/render/comment/deleteById?id=${comment.id}','${comment.id}');">删除</a>
                                                    </span>
                                                </td>
                                            </tr>
                                        </c:forEach>
                                    </c:if>
                                    <c:if test="${empty pb.beanList}">
                                        <li id="tuijian_content_1_empty" style="list-style: none;">暂无评论！</li>
                                    </c:if>
                                </tbody>
                            </table>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="clear"></div>
    <div class="pagination">
        <c:if test="${!empty pb.beanList}">
            <ul>
            <li>
                <span><a href="/render/comment/list?id=${cid}&pc=1">首页</a></span>
            </li>
            <%--上一页 --%>
            <li>
                <c:choose>
                    <c:when test="${pb.pc eq 1 }">
                        <span>上一页</span>
                    </c:when>
                    <c:otherwise>
                        <span><a href="/render/comment/list?id=${cid}&pc=${pb.pc-1}">上一页</a></span>
                    </c:otherwise>
                </c:choose>
            </li>

            <c:choose>
                <c:when test="${pb.tp <= 6 }">
                    <c:set var="begin" value="1"/>
                    <c:set var="end" value="${pb.tp }"/>
                </c:when>
                <c:otherwise>
                    <c:set var="begin" value="${pb.pc-2 }"/>
                    <c:set var="end" value="${pb.pc + 3}"/>
                    <c:if test="${begin < 1 }">
                        <c:set var="begin" value="1"/>
                        <c:set var="end" value="6"/>
                    </c:if>
                    <c:if test="${end > pb.tp }">
                        <c:set var="begin" value="${pb.tp-5 }"/>
                        <c:set var="end" value="${pb.tp }"/>
                    </c:if>
                </c:otherwise>
            </c:choose>

            <c:forEach begin="${begin }" end="${end }" var="i">
                <c:choose>
                    <c:when test="${i eq pb.pc }">
                        <li><span class="spanBtnSelect">${i}</span></li>
                    </c:when>
                    <c:otherwise>
                        <li><span><a href="/render/comment/list?id=${cid}&pc=${i}" class="aBtn">${i}</a></span></li>
                    </c:otherwise>
                </c:choose>
            </c:forEach>

            <c:if test="${end < pb.tp }">
                <span class="spanApostrophe">...</span>
            </c:if>

            <%--下一页 --%>
            <li>
                <c:choose>
                    <c:when test="${pb.pc eq pb.tp }">
                        <span>下一页</span>
                    </c:when>
                    <c:otherwise>
                        <span><a href="/render/comment/list?id=${cid}&pc=${pb.pc+1}">下一页</a></span>
                    </c:otherwise>
                </c:choose>
            </li>
            <li>
                <c:choose>
                    <c:when test="${pb.pc eq pb.tp }">
                        <span>末页</span>
                    </c:when>
                    <c:otherwise>
                        <span><a href="/render/comment/list?id=${cid}&pc=${pb.tp}">末页</a></span>
                    </c:otherwise>
                </c:choose>
            </li>
        </ul>
        </c:if>
    </div>

    <!-- 右边购物列表 End -->
</div>
<!-- 我的个人中心 End -->

<!-- Footer - wll -->
<jsp:include page="common/footer.jsp"></jsp:include>
<!-- Footer End -->

<script type="text/javascript">
    function deleteComment(url, id) {
        /*删除带有id的tr*/
        $.ajax({
            type: 'post',
            url: url,
            success: function (data) {
                if (data.success){
                    HFalert({title:data.message, type: 'success', confirmButtonText: '确定'});
                    $('#'+id).remove();
                } else {
                    HFalert({title:data.message, type: 'warning', confirmButtonText: '确定'});
                }
            }
        });
    }
</script>
</body>
</html>